home *** CD-ROM | disk | FTP | other *** search
/ Take-Home Tutor en Espanol / TakeHomeTutor.iso / pc / En espanol / Take-Home Tutor 3 / template_dashboard.swf / scripts / frame_1 / DoAction.as
Encoding:
Text File  |  2004-09-30  |  50.2 KB  |  1,821 lines

  1. function ext_XML_GET_TEXT()
  2. {
  3.    return this.firstChild.nodeType != 3 ? null : this.firstChild.nodeValue;
  4. }
  5. function ext_XML_SET_TEXT(text)
  6. {
  7.    this.firstChild.nodeValue = text;
  8. }
  9. function ActivityInfoItem()
  10. {
  11. }
  12. function ActivityInfo()
  13. {
  14. }
  15. function Queue()
  16. {
  17.    this.q = new Array();
  18. }
  19. function setVisible(bIsVisible)
  20. {
  21.    hideDialogs();
  22.    this._visible = bIsVisible;
  23.    videoPlayer.stopVideo();
  24.    videoPlayer.unloadVideo();
  25.    audioPlayer.reset();
  26. }
  27. function hideDialogs()
  28. {
  29.    modelDialog._visible = false;
  30.    zoomWin._visible = false;
  31. }
  32. function setActivityNumber(num)
  33. {
  34.    var tmc = actBullet.content;
  35.    trace(tmc);
  36.    var tf = layoutInfo.actBulletTextFormat;
  37.    tmc.embedFonts = true;
  38.    tmc.border = false;
  39.    tmc.color = layoutInfo.actBulletTextColor;
  40.    tmc.autoSize = "center";
  41.    tmc.type = "dynamic";
  42.    tmc.selectable = false;
  43.    tmc.text = num;
  44.    tmc.setTextFormat(tf);
  45. }
  46. function init()
  47. {
  48.    if(PMSI.NavKey.getCourse().toLowerCase() == "c1")
  49.    {
  50.       btnToggleLang._visible = false;
  51.    }
  52.    btnRefWin.isMoveable = true;
  53.    createTextField("score",10,0,0,0,0);
  54.    score.embedFonts = true;
  55.    score.selectable = false;
  56.    modelDialog._visible = false;
  57.    modelDialog.swapDepths(1201);
  58.    zoomWin._visible = false;
  59.    debug._visible = true;
  60.    actBullet.createTextField("content",1,0,0,0,0);
  61.    var tmc = actBullet.content;
  62.    trace(tmc);
  63.    var tf = layoutInfo.actBulletTextFormat;
  64.    tmc.embedFonts = true;
  65.    tmc.border = false;
  66.    tmc.color = layoutInfo.actBulletTextColor;
  67.    tmc.autoSize = "center";
  68.    tmc.type = "dynamic";
  69.    tmc.selectable = false;
  70.    tmc.text = "12";
  71.    tmc.setTextFormat(tf);
  72.    tmc._x = 0;
  73.    tmc._y = -1;
  74.    btnRefWin._visible = false;
  75.    loader.onComplete = function()
  76.    {
  77.       trace("Finished loading");
  78.    };
  79.    loader.setQueue(templateQueue);
  80.    loader.start();
  81. }
  82. function hideAll()
  83. {
  84. }
  85. function setActivityInfo(ai)
  86. {
  87.    videoNote.removeMovieClip();
  88.    videoPlayer.stopVideo();
  89.    videoPlayer.unloadVideo();
  90.    hideDialogs();
  91.    btnRefWin._visible = false;
  92.    mediaFrame._visible = false;
  93.    this.hasMediaFrame = false;
  94.    this.hasVideoPlayer = false;
  95.    this.hasAudioPlayer = false;
  96.    score.text = "";
  97.    audioPlayer.reset();
  98.    var i = 0;
  99.    while(i < templateList.length)
  100.    {
  101.       this[templateList[i].name]._visible = false;
  102.       i++;
  103.    }
  104.    this.ai = ai;
  105.    var type = activityTypes[ai.type];
  106.    actBullet.content.autoSize = "center";
  107.    setActivityNumber(ai.activityNumber.text);
  108.    trace(actBullet.content.text);
  109.    if(ai.artFile)
  110.    {
  111.       scriptTrace._visible = false;
  112.       mediaFrame._visible = true;
  113.       mediaFrame.showArt();
  114.       mediaFrame.attachImage(artPath + "/" + ai.artFile.text);
  115.       this.hasMediaFrame = true;
  116.    }
  117.    else
  118.    {
  119.       mediaFrame._visible = false;
  120.    }
  121.    if(ai.videoFile)
  122.    {
  123.       this.hasVideoPlayer = true;
  124.       this.hasMediaFrame = true;
  125.       videoPlayer.loadVideoClip(videoPath + "/" + fixVideoName(ai.videoFile.text));
  126.       trace("VIDEO PATH!!!: " + videoPath + "/" + fixVideoName(ai.videoFile.text));
  127.       videoPlayer._visible = true;
  128.       mediaFrame._visible = true;
  129.       scriptTrace._visible = true;
  130.       mediaFrame.showScript();
  131.       mediaFrame.setScriptWindowVisible(PMSI.scriptWindowVisible != null ? PMSI.scriptWindowVisible : true);
  132.       tallLine._visible = false;
  133.       actBullet._y = videoPlayer._y + videoPlayer._height / 2 + 10;
  134.       mediaFrame.scriptFile = getScriptFilenameFix();
  135.       mediaFrame.scriptAudioFile = getAudioFilenameFix();
  136.       loadScriptText(ai.videoScriptFile.text);
  137.    }
  138.    else
  139.    {
  140.       tallLine._visible = true;
  141.       actBullet._y = actBulletPosition.topy;
  142.       videoPlayer._visible = false;
  143.       scriptTrace._visible = false;
  144.    }
  145.    if(ai.audioFile)
  146.    {
  147.       this.hasAudioPlayer = true;
  148.       audioPlayer._visible = true;
  149.       var sndFile = audioPath + "/" + ai.audioFile.text;
  150.       trace(sndFile);
  151.       audioPlayer.loadSoundFile(sndFile);
  152.    }
  153.    else
  154.    {
  155.       audioPlayer._visible = false;
  156.    }
  157.    if(ai.audioScriptFile)
  158.    {
  159.       actBullet._y = actBulletPosition.topy;
  160.       this.hasAudioPlayer = true;
  161.       this.hasMediaFrame = true;
  162.       mediaFrame._visible = true;
  163.       scriptTrace._visible = true;
  164.       mediaFrame.showScript();
  165.       mediaFrame.setScriptWindowVisible(PMSI.scriptWindowVisible != null ? PMSI.scriptWindowVisible : true);
  166.       tallLine._visible = true;
  167.       mediaFrame.scriptFile = ai.audioScriptFile.text;
  168.       mediaFrame.scriptAudioFile = getAudioFilenameFix();
  169.       trace("\taudioScriptFile: " + ai.audioScriptFile.text);
  170.       loadAudioScriptText(ai.audioScriptFile.text);
  171.    }
  172.    if(ai.audioFile)
  173.    {
  174.       answerBtn._x = actAnswerPosition.pos2_x;
  175.       answerBtn._y = actAnswerPosition.pos2_y;
  176.    }
  177.    else
  178.    {
  179.       answerBtn._x = actAnswerPosition.pos1_x;
  180.       answerBtn._y = actAnswerPosition.pos1_y;
  181.    }
  182.    if(parseInt(ai.type.text) != activityTypes.MATCH && ai.artFile == null && ai.wordBank != null && parseInt(ai.type.text) != activityTypes.TABLE)
  183.    {
  184.       trace("*!*!:: THIS SHOULD GET A WORD LIST");
  185.       trace("\ttype: " + ai.type);
  186.       mediaFrame._visible = true;
  187.       mediaFrame.showWordlist(ai.wordBank.word);
  188.       this.hasMediaFrame = true;
  189.    }
  190.    mediaFrame.setSmallFrame(this.hasAudioPlayer && this.hasMediaFrame && !this.hasVideoPlayer,ai.audioScriptFile != null);
  191.    scriptTrace.setSmallFrame(this.hasAudioPlayer && this.hasMediaFrame && !this.hasVideoPlayer);
  192.    this.currentActivity = this[type];
  193.    this[type]._visible = true;
  194.    answerBtn.tabIndex = 10000;
  195.    answerBtn._visible = true;
  196.    actNumber_mc._visible = true;
  197.    actBullet._visible = true;
  198.    this[type].btnRefWin = btnRefWin;
  199.    if(ai.type.text == "7")
  200.    {
  201.       initStageForUnitVideos();
  202.    }
  203.    return this[type].setActivityInfo(ai);
  204. }
  205. function loadScriptText(url)
  206. {
  207.    scriptTrace.loadXML(scriptPath + "/" + getScriptFilenameFix());
  208. }
  209. function loadAudioScriptText(url)
  210. {
  211.    scriptTrace.loadXML(scriptPath + "/" + url);
  212. }
  213. function getScriptFilenameFix()
  214. {
  215.    return ai.videoScriptFile != null ? ai.videoScriptFile.text : ai.audioScriptFile.text;
  216. }
  217. function getAudioFilenameFix()
  218. {
  219.    var sf = ai.videoScriptFile != null ? ai.videoScriptFile.text : ai.audioScriptFile.text;
  220.    return sf.substring(0,sf.lastIndexOf(".")) + ".mp3";
  221. }
  222. function fixVideoName(url, character)
  223. {
  224.    return url;
  225. }
  226. function setFeedBack(correct, outof)
  227. {
  228.    trace("setting feedback");
  229.    var isScr = ai.isScoreable.text != "y" ? false : true;
  230.    PMSI.Session.score.incrementActivitiesAttempted(isScr);
  231.    PMSI.Session.score.incrementQuestionsAttempted(outof);
  232.    PMSI.Session.score.incrementQuestionsCorrect(correct);
  233.    PMSI.Session.scoring.setActivityScore(correct,outof,isScr);
  234.    score.autoSize = true;
  235.    if(isScr)
  236.    {
  237.       score.text = correct != outof ? "Try Again" : "Correct";
  238.       score.setTextFormat(layoutInfo.actFeedbackTextFormat);
  239.    }
  240.    score._y = answerBtn._y + 5;
  241.    score._x = answerBtn._x - score._width - 20;
  242.    if(!isScr && !(ai.questions.question instanceof Array) && ai.questions.question.correctAnswer != null)
  243.    {
  244.       var mdl = "";
  245.       if(ai.questions.question.correctAnswer instanceof Array)
  246.       {
  247.          var i = 0;
  248.          while(i < ai.questions.question.correctAnswer.length)
  249.          {
  250.             mdl += ai.questions.question.correctAnswer[i].text.trim() + "\n\n";
  251.             i++;
  252.          }
  253.          showModelDialog(mdl);
  254.       }
  255.       else
  256.       {
  257.          showModelDialog(ai.questions.question.correctAnswer);
  258.       }
  259.    }
  260.    else if(!isScr && ai.model == null && ai.questions.question[0].model == null || !isScr && ai.questions.question[0].correctAnswer != null)
  261.    {
  262.       var mdl = "";
  263.       var i = 0;
  264.       while(i < ai.questions.question.length)
  265.       {
  266.          if(ai.questions.question[i].correctAnswer != null)
  267.          {
  268.             mdl += i + 1 + ". ";
  269.             if(ai.questions.question[i].questionText != null && ai.type.text != "2")
  270.             {
  271.                mdl += ai.questions.question[i].questionText + "\n";
  272.             }
  273.             mdl += ai.questions.question[i].correctAnswer.text.trim() + "\n\n";
  274.          }
  275.          i++;
  276.       }
  277.       if(mdl == "")
  278.       {
  279.          showModelDialog("[No model supplied]");
  280.       }
  281.       else
  282.       {
  283.          showModelDialog(mdl);
  284.       }
  285.    }
  286.    else if(!isScr)
  287.    {
  288.       showModelDialog(ai.model.text.trim());
  289.    }
  290. }
  291. function showModelDialog(model)
  292. {
  293.    modelDialog.model_txt.scroll = 0;
  294.    modelDialog.model_txt.text = model;
  295.    modelDialog._visible = true;
  296.    modelDialog.centerDialog();
  297. }
  298. function loadActivity(url)
  299. {
  300.    loadingBox._visible = true;
  301.    var fn = "activities/data/" + url;
  302.    trace("XML File full filename: " + fn);
  303.    actInfo.onLoad = actOnLoad;
  304.    actInfo.load(fn);
  305.    Mouse.show();
  306. }
  307. function actOnLoad()
  308. {
  309.    setActivityInfo(actInfo);
  310.    answerBtn.enabled = true;
  311.    zoomWin._visible = false;
  312. }
  313. function setActivityList(actlist)
  314. {
  315.    this.actlist = actlist;
  316.    actNumber_mc.setActivityList(actlist);
  317.    trace("Listing Activities");
  318.    var i = 0;
  319.    while(i < actlist.length)
  320.    {
  321.       trace("\t" + actlist[i]);
  322.       i++;
  323.    }
  324. }
  325. function onRender()
  326. {
  327.    loadingBox._visible = false;
  328. }
  329. function closeRecorder()
  330. {
  331.    mediaFrame.closeRecorder();
  332. }
  333. function toggleLang()
  334. {
  335.    currentActivity.toggleLang();
  336. }
  337. function setRefWinVisible(bIsVisible)
  338. {
  339.    if(refWin == null)
  340.    {
  341.       this.attachMovie("refWin","refWin",2000);
  342.    }
  343.    refWin._x = 10;
  344.    refWin._y = 10;
  345.    refWin._visible = bIsVisible;
  346. }
  347. function testRefWin()
  348. {
  349.    trace("Setting refWin to visible");
  350.    setRefWinVisible(true);
  351. }
  352. function showRefWinButton(x, y)
  353. {
  354.    btnRefWin._x = x;
  355.    btnRefWin._y = y;
  356.    btnRefWin._visible = true;
  357.    if(refWin == null)
  358.    {
  359.       this.attachMovie("refWin","refWin",2000);
  360.    }
  361.    refWin._visible = false;
  362. }
  363. function initStageForUnitVideos()
  364. {
  365.    actNumber_mc._visible = false;
  366.    actBullet._visible = false;
  367.    answerBtn._visible = false;
  368.    shortLine._visible = false;
  369.    tallLine._visible = false;
  370.    audioPlayer._visible = false;
  371.    this.hasVideoPlayer = true;
  372.    this.hasMediaFrame = true;
  373.    videoPlayer.loadVideoClip(videoPath + "/" + fixVideoName(ai.videoFile.text));
  374.    trace("VIDEO PATH!!!: " + videoPath + "/" + fixVideoName(ai.videoFile.text));
  375.    videoPlayer._visible = true;
  376.    mediaFrame._visible = true;
  377.    scriptTrace._visible = true;
  378.    mediaFrame.showScript();
  379.    mediaFrame.setScriptWindowVisible(PMSI.scriptWindowVisible != null ? PMSI.scriptWindowVisible : true);
  380.    actBullet._y = videoPlayer._y + videoPlayer._height / 2 + 10;
  381.    mediaFrame.scriptFile = getScriptFilenameFix();
  382.    mediaFrame.scriptAudioFile = getAudioFilenameFix();
  383.    loadScriptText(ai.videoScriptFile.text);
  384. }
  385. function hideAllTemplates()
  386. {
  387.    var i = 0;
  388.    while(i < templateList.length)
  389.    {
  390.       trace("HIDING TEMPLATE: " + templateList[i].name);
  391.       this[templateList[i].name]._visible = false;
  392.       i++;
  393.    }
  394. }
  395. if(_global.PMSI == null)
  396. {
  397.    _global.PMSI = {};
  398.    PMSI.VENDOR_NAME = "Purple Monkey Studios, Inc.";
  399.    PMSI.DefList = {};
  400. }
  401. String.prototype.trim = function()
  402. {
  403.    return this.rtrim().ltrim();
  404. };
  405. String.prototype.rtrim = function()
  406. {
  407.    var i = this.length - 1;
  408.    while(i >= 0 && this.charCodeAt(i) <= 32)
  409.    {
  410.       i--;
  411.    }
  412.    return this.substring(0,i + 1);
  413. };
  414. String.prototype.ltrim = function()
  415. {
  416.    var i = 0;
  417.    while(i < this.length && this.charCodeAt(i) <= 32)
  418.    {
  419.       i++;
  420.    }
  421.    return this.substring(i);
  422. };
  423. String.prototype.isWhiteSpace = function()
  424. {
  425.    var i = 0;
  426.    while(i < this.length)
  427.    {
  428.       if(this.charCodeAt(i) > 32)
  429.       {
  430.          return false;
  431.       }
  432.       i++;
  433.    }
  434.    return true;
  435. };
  436. String.prototype.toCharArray = function()
  437. {
  438.    return this.split("");
  439. };
  440. Array.prototype.charArrayToString = function()
  441. {
  442.    return this.join("");
  443. };
  444. String.prototype.reverse = function()
  445. {
  446.    return this.split("").reverse().join("");
  447. };
  448. String.prototype.multiSplit = function()
  449. {
  450.    var master;
  451.    var dummy;
  452.    var args;
  453.    master = this.split(arguments[0]);
  454.    var i = 1;
  455.    while(i < arguments.length)
  456.    {
  457.       var j = 0;
  458.       while(j < master.length)
  459.       {
  460.          dummy = master[j].split(arguments[i]);
  461.          if(dummy.length > 1)
  462.          {
  463.             args = [j,1];
  464.             args = args.concat(dummy);
  465.             master.splice.apply(master,args);
  466.          }
  467.          j++;
  468.       }
  469.       i++;
  470.    }
  471.    return master;
  472. };
  473. String.prototype.replace = function(srch, repl)
  474. {
  475.    return this.split(srch).join(repl);
  476. };
  477. XML.prototype.ELEMENT_NODE = 1;
  478. XML.prototype.TEXT_NODE = 3;
  479. XML.prototype._inorderItr = function(node, fnPtr)
  480. {
  481.    var stack = new Array();
  482.    var node = node;
  483.    while(true)
  484.    {
  485.       if(node)
  486.       {
  487.          stack.push(node);
  488.          node = node.firstChild;
  489.       }
  490.       else
  491.       {
  492.          node = stack.pop();
  493.          if(!node)
  494.          {
  495.             break;
  496.          }
  497.          fnPtr(node);
  498.          node = node.nextSibling;
  499.       }
  500.    }
  501.    delete stack;
  502. };
  503. XMLNode.prototype._inorderItr = XML.prototype._inorderItr;
  504. XML.prototype._inorderRec = function(node, fnPtr)
  505. {
  506.    function helperR(node_xml)
  507.    {
  508.       if(node_xml == null)
  509.       {
  510.          return undefined;
  511.       }
  512.       this.fnPtr(node_xml);
  513.       helperR(node_xml.firstChild);
  514.       helperR(node_xml.nextSibling);
  515.    }
  516.    var outer = this;
  517.    helperR(node);
  518. };
  519. XMLNode.prototype._inorderRec = XML.prototype._inorderRec;
  520. XMLNode.prototype.addProperty("text",this.ext_XML_GET_TEXT,this.ext_XML_SET_TEXT);
  521. XML.prototype.addProperty("text",this.ext_XML_GET_TEXT,this.ext_XML_SET_TEXT);
  522. XML.prototype.getElementsByTagName = function(tagName)
  523. {
  524.    function processNode(node)
  525.    {
  526.       if(node.nodeName != null && node.nodeName == tagName)
  527.       {
  528.          nodelist.push(node);
  529.       }
  530.    }
  531.    var nodelist = new Array();
  532.    this._inorderItr(this,processNode);
  533.    return nodelist;
  534. };
  535. XMLNode.prototype.getElementsByTagName = XML.prototype.getElementsByTagName;
  536. XML.prototype.getElementsByTagNames = function()
  537. {
  538.    function processNode(node)
  539.    {
  540.       var i = 0;
  541.       while(i < args.length)
  542.       {
  543.          if(node.nodeName != null && node.nodeName == args[i])
  544.          {
  545.             trace("Found: " + args[i]);
  546.             if(nodelists[i] == undefined)
  547.             {
  548.                nodelists[i] = new Array();
  549.             }
  550.             nodelists[i].push(node);
  551.             break;
  552.          }
  553.          i++;
  554.       }
  555.    }
  556.    var args = arguments;
  557.    var nodelists = new Array(arguments.length);
  558.    this._inorderItr(this,processNode);
  559.    return nodelists;
  560. };
  561. XMLNode.prototype.getElementsByTagNames = XML.prototype.getElementsByTagNames;
  562. XML.prototype.getValueAtTagName = function(tagName)
  563. {
  564.    function processNode(node)
  565.    {
  566.       if(node.nodeName != null && node.nodeName == tagName)
  567.       {
  568.          nodelist.push(node);
  569.       }
  570.    }
  571.    var nodelist = new Array();
  572.    var textValue = null;
  573.    this._inorderItr(this,processNode);
  574.    if(nodeList.length >= 1)
  575.    {
  576.       textValue = nodeList[0].text;
  577.    }
  578.    return textValue;
  579. };
  580. XMLNode.prototype.getValueAtTagName = XML.prototype.getValueAtTagName;
  581. XML.prototype.getAttribute = function(name)
  582. {
  583.    return this.attributes[name];
  584. };
  585. XMLNode.prototype.getAttribute = XML.prototype.getAttribute;
  586. XML.prototype.setAttribute = function(name, value)
  587. {
  588.    this.attributes[name] = value;
  589. };
  590. XMLNode.prototype.setAttribute = XML.prototype.setAttribute;
  591. XML.prototype.hasAttribute = function(name)
  592. {
  593.    var attrs = this.attributes;
  594.    for(var mc in attrs)
  595.    {
  596.       if(name == mc)
  597.       {
  598.          return true;
  599.       }
  600.    }
  601.    return false;
  602. };
  603. XMLNode.prototype.hasAttribute = XML.prototype.hasAttribute;
  604. XML.prototype.removeAttribute = function(name)
  605. {
  606.    var attr = this.attributes[name];
  607.    delete this.attributes[name];
  608.    return attr;
  609. };
  610. XMLNode.prototype.setAttribute = XML.prototype.setAttribute;
  611. XMLNode.prototype.getOwnerDocument = function()
  612. {
  613.    var odc = this;
  614.    var lastNode = this;
  615.    while(odc)
  616.    {
  617.       lastNode = odc;
  618.       odc = odc.parentNode;
  619.    }
  620.    return !(lastNode instanceof XML) ? null : lastNode;
  621. };
  622. XML.prototype.normalize = function()
  623. {
  624.    function process(node)
  625.    {
  626.       nodeList.push(node);
  627.    }
  628.    var outer = this;
  629.    var nodeList = new Array();
  630.    this._inorderItr(this,process);
  631.    var i = 0;
  632.    while(i < nodeList.length)
  633.    {
  634.       var node = nodeList[i];
  635.       if(node.nodeType == XML.prototype.TEXT_NODE && node.nodeValue.isWhiteSpace())
  636.       {
  637.          trace("removing node");
  638.          node.removeNode();
  639.       }
  640.       else if(node.nodeType == XML.prototype.TEXT_NODE)
  641.       {
  642.          node.nodeValue = node.nodeValue.trim();
  643.       }
  644.       i++;
  645.    }
  646.    delete nodeList;
  647. };
  648. XMLNode.prototype.normalize = XML.prototype.normalize;
  649. XMLNode.prototype.getDepth = function()
  650. {
  651.    var i = 0;
  652.    var node = this;
  653.    while(node)
  654.    {
  655.       node = node.parentNode;
  656.       i++;
  657.    }
  658.    return i;
  659. };
  660. XML.prototype.getElementsWithAttribute = function(name, value)
  661. {
  662.    function processNode(node)
  663.    {
  664.       if(value == null)
  665.       {
  666.          for(var mcz in node.attributes)
  667.          {
  668.             if(mcz == name)
  669.             {
  670.                nodeList.push(node);
  671.                break;
  672.             }
  673.          }
  674.       }
  675.       else if(node.attributes[name] == value)
  676.       {
  677.          nodeList.push(node);
  678.       }
  679.    }
  680.    if(name == null)
  681.    {
  682.       return undefined;
  683.    }
  684.    var nodeList = new Array();
  685.    this._inorderItr(this,processNode);
  686.    return nodeList;
  687. };
  688. XMLNode.prototype.getElementsWithAttribute = XML.prototype.getElementsWithAttribute;
  689. XMLNode.prototype.getPath = function(path)
  690. {
  691.    function process(node)
  692.    {
  693.       trace(node.nodeName);
  694.       if(node.nodeName != null && node.nodeName == currentPart && i < pathParts.length)
  695.       {
  696.          trace("Found: " + currentPart);
  697.          partTable[i] = node.parentNode.getElementsByTagName(currentPart);
  698.          currentPart = pathParts[++i];
  699.       }
  700.    }
  701.    var i = 0;
  702.    var pathParts = path.split("/");
  703.    var currentPart = pathParts[i];
  704.    var partTable = new Array();
  705.    this._inorderItr(this,process);
  706.    return partTable[partTable.length - 1];
  707. };
  708. XML.prototype.getPath = XMLNode.prototype.getPath;
  709. MovieClip.prototype.isLoading = function()
  710. {
  711.    return this.getBytesLoaded() > 4 && this.getBytesTotal() > this.getBytesLoaded();
  712. };
  713. MovieClip.prototype.getPercentLoaded = function()
  714. {
  715.    return Math.round(this.getBytesLoaded() / this.getBytesTotal() * 100);
  716. };
  717. MovieClip.prototype.isLoaded = function()
  718. {
  719.    return !this.isLoading();
  720. };
  721. MovieClip.prototype._sol = function(f)
  722. {
  723.    if(MovieClip.prototype.__onLoadHandler__ == undefined)
  724.    {
  725.       MovieClip.prototype.__onLoadHandler__ = {};
  726.    }
  727.    MovieClip.prototype.__onLoadHandler__[this] = f;
  728. };
  729. MovieClip.prototype._gol = function()
  730. {
  731.    return MovieClip.prototype.__onLoadHandler__[this];
  732. };
  733. MovieClip.prototype.addProperty("onLoad",MovieClip.prototype._gol,MovieClip.prototype._sol);
  734. MovieClip.prototype._sod = function(f)
  735. {
  736.    if(MovieClip.prototype.__onDataHandler__ == undefined)
  737.    {
  738.       MovieClip.prototype.__onDataHandler__ = {};
  739.    }
  740.    MovieClip.prototype.__onDataHandler__[this] = f;
  741. };
  742. MovieClip.prototype._god = function()
  743. {
  744.    return MovieClip.prototype.__onDataHandler__[this];
  745. };
  746. MovieClip.prototype.addProperty("onData",MovieClip.prototype._god,MovieClip.prototype._sod);
  747. MovieClip.prototype.load = MovieClip.prototype.loadMovie;
  748. MovieClip.prototype.drawOval = function(x, y, radius, yRadius)
  749. {
  750.    if(arguments.length < 3)
  751.    {
  752.       return undefined;
  753.    }
  754.    var theta;
  755.    var xrCtrl;
  756.    var yrCtrl;
  757.    var angle;
  758.    var angleMid;
  759.    var px;
  760.    var py;
  761.    var cx;
  762.    var cy;
  763.    if(yRadius == undefined)
  764.    {
  765.       yRadius = radius;
  766.    }
  767.    theta = 0.7853981633974483;
  768.    xrCtrl = radius / Math.cos(theta / 2);
  769.    yrCtrl = yRadius / Math.cos(theta / 2);
  770.    angle = 0;
  771.    this.moveTo(x + radius,y);
  772.    var i = 0;
  773.    while(i < 8)
  774.    {
  775.       angle += theta;
  776.       angleMid = angle - theta / 2;
  777.       cx = x + Math.cos(angleMid) * xrCtrl;
  778.       cy = y + Math.sin(angleMid) * yrCtrl;
  779.       px = x + Math.cos(angle) * radius;
  780.       py = y + Math.sin(angle) * yRadius;
  781.       this.curveTo(cx,cy,px,py);
  782.       i++;
  783.    }
  784. };
  785. MovieClip.prototype.drawCircle = function(x, y, r)
  786. {
  787.    this.drawOval(x,y,r);
  788. };
  789. MovieClip.prototype.drawSquare = function(x, y, w)
  790. {
  791.    this.drawRect(x,y,w,w);
  792. };
  793. MovieClip.prototype.drawEgg = function(x, y, r)
  794. {
  795.    var rx = r / 1.618;
  796.    var ry = r;
  797.    var ry1 = 2 * ry * 0.618;
  798.    var ry2 = 2 * ry * 0.382;
  799.    this.moveTo(x + rx,y);
  800.    this.curveTo(rx + x,-0.4142 * ry1 + y,0.7071 * rx + x,-0.7071 * ry1 + y);
  801.    this.curveTo(0.4142 * rx + x,- ry1 + y,x,- ry1 + y);
  802.    this.curveTo(-0.4142 * rx + x,- ry1 + y,-0.7071 * rx + x,-0.7071 * ry1 + y);
  803.    this.curveTo(- rx + x,-0.4142 * ry1 + y,- rx + x,y);
  804.    this.curveTo(- rx + x,0.4142 * ry2 + y,-0.7071 * rx + x,0.7071 * ry2 + y);
  805.    this.curveTo(-0.4142 * rx + x,ry2 + y,x,ry2 + y);
  806.    this.curveTo(0.4142 * rx + x,ry2 + y,0.7071 * rx + x,0.7071 * ry2 + y);
  807.    this.curveTo(rx + x,0.4142 * ry2 + y,rx + x,y);
  808. };
  809. MovieClip.prototype.drawRect = function(x, y, w, h, cornerRadius)
  810. {
  811.    if(arguments.length < 4)
  812.    {
  813.       return undefined;
  814.    }
  815.    if(cornerRadius > 0)
  816.    {
  817.       var theta;
  818.       var angle;
  819.       var cx;
  820.       var cy;
  821.       var px;
  822.       var py;
  823.       if(cornerRadius > Math.min(w,h) / 2)
  824.       {
  825.          cornerRadius = Math.min(w,h) / 2;
  826.       }
  827.       theta = 0.7853981633974483;
  828.       this.moveTo(x + cornerRadius,y);
  829.       this.lineTo(x + w - cornerRadius,y);
  830.       angle = -1.5707963267948966;
  831.       cx = x + w - cornerRadius + Math.cos(angle + theta / 2) * cornerRadius / Math.cos(theta / 2);
  832.       cy = y + cornerRadius + Math.sin(angle + theta / 2) * cornerRadius / Math.cos(theta / 2);
  833.       px = x + w - cornerRadius + Math.cos(angle + theta) * cornerRadius;
  834.       py = y + cornerRadius + Math.sin(angle + theta) * cornerRadius;
  835.       this.curveTo(cx,cy,px,py);
  836.       angle += theta;
  837.       cx = x + w - cornerRadius + Math.cos(angle + theta / 2) * cornerRadius / Math.cos(theta / 2);
  838.       cy = y + cornerRadius + Math.sin(angle + theta / 2) * cornerRadius / Math.cos(theta / 2);
  839.       px = x + w - cornerRadius + Math.cos(angle + theta) * cornerRadius;
  840.       py = y + cornerRadius + Math.sin(angle + theta) * cornerRadius;
  841.       this.curveTo(cx,cy,px,py);
  842.       this.lineTo(x + w,y + h - cornerRadius);
  843.       angle += theta;
  844.       cx = x + w - cornerRadius + Math.cos(angle + theta / 2) * cornerRadius / Math.cos(theta / 2);
  845.       cy = y + h - cornerRadius + Math.sin(angle + theta / 2) * cornerRadius / Math.cos(theta / 2);
  846.       px = x + w - cornerRadius + Math.cos(angle + theta) * cornerRadius;
  847.       py = y + h - cornerRadius + Math.sin(angle + theta) * cornerRadius;
  848.       this.curveTo(cx,cy,px,py);
  849.       angle += theta;
  850.       cx = x + w - cornerRadius + Math.cos(angle + theta / 2) * cornerRadius / Math.cos(theta / 2);
  851.       cy = y + h - cornerRadius + Math.sin(angle + theta / 2) * cornerRadius / Math.cos(theta / 2);
  852.       px = x + w - cornerRadius + Math.cos(angle + theta) * cornerRadius;
  853.       py = y + h - cornerRadius + Math.sin(angle + theta) * cornerRadius;
  854.       this.curveTo(cx,cy,px,py);
  855.       this.lineTo(x + cornerRadius,y + h);
  856.       angle += theta;
  857.       cx = x + cornerRadius + Math.cos(angle + theta / 2) * cornerRadius / Math.cos(theta / 2);
  858.       cy = y + h - cornerRadius + Math.sin(angle + theta / 2) * cornerRadius / Math.cos(theta / 2);
  859.       px = x + cornerRadius + Math.cos(angle + theta) * cornerRadius;
  860.       py = y + h - cornerRadius + Math.sin(angle + theta) * cornerRadius;
  861.       this.curveTo(cx,cy,px,py);
  862.       angle += theta;
  863.       cx = x + cornerRadius + Math.cos(angle + theta / 2) * cornerRadius / Math.cos(theta / 2);
  864.       cy = y + h - cornerRadius + Math.sin(angle + theta / 2) * cornerRadius / Math.cos(theta / 2);
  865.       px = x + cornerRadius + Math.cos(angle + theta) * cornerRadius;
  866.       py = y + h - cornerRadius + Math.sin(angle + theta) * cornerRadius;
  867.       this.curveTo(cx,cy,px,py);
  868.       this.lineTo(x,y + cornerRadius);
  869.       angle += theta;
  870.       cx = x + cornerRadius + Math.cos(angle + theta / 2) * cornerRadius / Math.cos(theta / 2);
  871.       cy = y + cornerRadius + Math.sin(angle + theta / 2) * cornerRadius / Math.cos(theta / 2);
  872.       px = x + cornerRadius + Math.cos(angle + theta) * cornerRadius;
  873.       py = y + cornerRadius + Math.sin(angle + theta) * cornerRadius;
  874.       this.curveTo(cx,cy,px,py);
  875.       angle += theta;
  876.       cx = x + cornerRadius + Math.cos(angle + theta / 2) * cornerRadius / Math.cos(theta / 2);
  877.       cy = y + cornerRadius + Math.sin(angle + theta / 2) * cornerRadius / Math.cos(theta / 2);
  878.       px = x + cornerRadius + Math.cos(angle + theta) * cornerRadius;
  879.       py = y + cornerRadius + Math.sin(angle + theta) * cornerRadius;
  880.       this.curveTo(cx,cy,px,py);
  881.    }
  882.    else
  883.    {
  884.       this.moveTo(x,y);
  885.       this.lineTo(x + w,y);
  886.       this.lineTo(x + w,y + h);
  887.       this.lineTo(x,y + h);
  888.       this.lineTo(x,y);
  889.    }
  890. };
  891. MovieClip.prototype.getCenterPoint = function()
  892. {
  893.    return {x:this._width / 2,y:this._height / 2};
  894. };
  895. MovieClip.prototype.drawDebugBorderD = function()
  896. {
  897.    this.lineStyle(1,0,25);
  898.    var x;
  899.    var y = 0;
  900.    var w = this._width;
  901.    var h = this._height;
  902.    this.moveTo(x,y);
  903.    this.lineTo(x + w,y);
  904.    this.lineTo(x + w,y + h);
  905.    this.lineTo(x,y + h);
  906.    this.lineTo(x,y);
  907. };
  908. MovieClip.prototype.drawUnderline = function(len)
  909. {
  910.    len = len != null ? len : this._width;
  911.    this.moveTo(0,this._height);
  912.    this.lineTo(len,this._height);
  913. };
  914. if(PMSI.DepthManager == undefined)
  915. {
  916.    PMSI.DepthManager = {};
  917.    PMSI.DepthManager._$depth = 0;
  918.    PMSI.DepthManager.getNextDepth = function()
  919.    {
  920.       var next_depth = ++this._$depth;
  921.       while(this._$depthsClaimed["dc" + next_depth])
  922.       {
  923.          next_depth = ++this._$depth;
  924.       }
  925.       return next_depth;
  926.    };
  927.    PMSI.DepthManager.reserveDepth = function(d)
  928.    {
  929.       if(this._$depthsClaimed == null)
  930.       {
  931.          this._$depthsClaimed = {};
  932.       }
  933.       if(d == null)
  934.       {
  935.          var d = ++this._$depth;
  936.       }
  937.       while(this._$depthsClaimed["dc" + d])
  938.       {
  939.          d++;
  940.       }
  941.       this._$depthsClaimed["dc" + d] = d;
  942.       return d;
  943.    };
  944. }
  945. ActivityInfoItem.prototype.toString = function()
  946. {
  947.    return this.text;
  948. };
  949. ActivityInfo.prototype.getIdString = function(separator)
  950. {
  951.    var sep = separator != null ? separator : ".";
  952.    var idStr = "C" + this.activity.course + sep;
  953.    idStr += "U" + this.activity.unit + sep;
  954.    idStr += "S" + this.activity.section + sep;
  955.    idStr += this.activity.topic + sep;
  956.    if(this.activity.topicSet)
  957.    {
  958.       idStr += this.activity.topicSet + sep;
  959.    }
  960.    idStr += this.activity.difficultyLevel + this.activity.number.text;
  961.    return idStr;
  962. };
  963. ActivityInfo.prototype.getId = ActivityInfo.prototype.getIdString;
  964. ActivityInfo.prototype.getType = function()
  965. {
  966.    return this.activity.type;
  967. };
  968. ActivityInfo.prototype.hasAudio = function()
  969. {
  970.    return this.activity.audioFile == null ? false : true;
  971. };
  972. ActivityInfo.prototype.hasVideo = function()
  973. {
  974.    return this.activity.videoFile == null ? false : true;
  975. };
  976. ActivityInfo.prototype.hasPicture = function()
  977. {
  978.    return this.activity.artFile == null ? false : true;
  979. };
  980. ActivityInfo.prototype.setResolve = function()
  981. {
  982.    this.__resolve = ActivityInfo.prototype._myResolve;
  983. };
  984. ActivityInfo.prototype._myResolve = function(name)
  985. {
  986.    return this.activity[name];
  987. };
  988. ActivityInfo.prototype.getBytesLoaded = function()
  989. {
  990.    return this.xmlSource.getBytesLoaded();
  991. };
  992. ActivityInfo.prototype.getBytesTotal = function()
  993. {
  994.    return this.xmlSource.getBytesTotal();
  995. };
  996. ActivityInfo.prototype.load = function(url)
  997. {
  998.    this._reset();
  999.    this.xmlSource = new XML();
  1000.    var x = this.xmlSource;
  1001.    x.parent = this;
  1002.    x.ignoreWhite = true;
  1003.    x.createAttributeArray = function(attrs)
  1004.    {
  1005.    };
  1006.    x.onLoad = function(success)
  1007.    {
  1008.       function helperR(node_xml, obj)
  1009.       {
  1010.          if(node_xml == null)
  1011.          {
  1012.             return undefined;
  1013.          }
  1014.          var nName = node_xml.nodeName;
  1015.          if(nName == "number")
  1016.          {
  1017.             nName = "activityNumber";
  1018.          }
  1019.          if(nName != null && obj[nName] == null)
  1020.          {
  1021.             var newObj = new ActivityInfoItem();
  1022.             newObj.text = node_xml.text.trim();
  1023.             if(node_xml.attributes)
  1024.             {
  1025.                trace("creating new attributes array");
  1026.                newObj.attributes = {};
  1027.                for(var oname in node_xml.attributes)
  1028.                {
  1029.                   newObj.attributes[oname] = node_xml.attributes[oname];
  1030.                }
  1031.             }
  1032.             obj[nName] = newObj;
  1033.          }
  1034.          else if(!(obj[nName] instanceof Array) && obj[nName] != null)
  1035.          {
  1036.             var temp = obj[nName];
  1037.             obj[nName] = [];
  1038.             obj[nName].push(temp);
  1039.          }
  1040.          var childObject = obj[nName];
  1041.          if(childObject instanceof Array)
  1042.          {
  1043.             var newObj = new ActivityInfoItem();
  1044.             newObj.text = node_xml.text.trim();
  1045.             if(node_xml.attributes)
  1046.             {
  1047.                trace("creating new attributes array");
  1048.                newObj.attributes = {};
  1049.                for(var oname in node_xml.attributes)
  1050.                {
  1051.                   newObj.attributes[oname] = node_xml.attributes[oname];
  1052.                }
  1053.             }
  1054.             childObject = newObj;
  1055.             obj[nName].push(childObject);
  1056.          }
  1057.          helperR(node_xml.firstChild,childObject);
  1058.          helperR(node_xml.nextSibling,obj);
  1059.       }
  1060.       if(success)
  1061.       {
  1062.          helperR(this.firstChild,this.parent);
  1063.          this.parent.setResolve();
  1064.       }
  1065.       this.parent.onLoad(success);
  1066.    };
  1067.    x.load(url);
  1068. };
  1069. ActivityInfo.prototype._reset = function()
  1070. {
  1071.    delete this.xmlSource;
  1072.    delete this.__resolve;
  1073.    delete this.activity;
  1074. };
  1075. TableClass = function(parent)
  1076. {
  1077.    this.parent = parent;
  1078.    this.reduceTextFields = true;
  1079.    this.rows = [];
  1080.    this.maxCellDims = {width:0,height:0};
  1081.    this.cellPadding = 4;
  1082.    this.cellSpacing = 4;
  1083.    this.colWidthMaxs = [];
  1084.    this.colPercentTable = [];
  1085.    this.borderSize = 1;
  1086.    this.width = 0;
  1087.    this.height = 0;
  1088.    this.oldWidth = this.width;
  1089.    this.oldHeight = this.oldHeight;
  1090.    this.originalWidth = 0;
  1091.    this.x = 0;
  1092.    this.y = 0;
  1093.    this.alteredColumns = {};
  1094.    var dep = PMSI.DepthManager.getNextDepth();
  1095.    this.borderClip = parent.createEmptyMovieClip("TableClassBorder" + dep,dep);
  1096. };
  1097. TableClass.prototype.setPosition = function(position)
  1098. {
  1099.    this.x = position.x;
  1100.    this.y = position.y;
  1101. };
  1102. TableClass.prototype.getPosition = function()
  1103. {
  1104.    return {x:this.x,y:this.y};
  1105. };
  1106. TableClass.prototype.setBorder = function(bsize)
  1107. {
  1108.    this.borderSize = bsize;
  1109. };
  1110. TableClass.prototype.addRow = function(newRow)
  1111. {
  1112.    this.rows.push(newRow);
  1113.    var cells = newRow.cells;
  1114.    var cellCount = cells.length;
  1115.    var cwms = this.colWidthMaxs;
  1116.    var cw = null;
  1117.    var newWidth = 0;
  1118.    var con = null;
  1119.    var c = 0;
  1120.    while(c < cellCount)
  1121.    {
  1122.       con = cells[c].getContent();
  1123.       cw = con == null ? cells[c].width : con._width;
  1124.       if(cwms[c] == null)
  1125.       {
  1126.          cwms[c] = cw;
  1127.       }
  1128.       else
  1129.       {
  1130.          cwms[c] = cw <= cwms[c] ? cwms[c] : cw;
  1131.       }
  1132.       newWidth += cwms[c];
  1133.       c++;
  1134.    }
  1135.    this.originalWidth = newWidth;
  1136.    this.width = newWidth;
  1137.    trace("NEW WIDTH: " + this.width);
  1138. };
  1139. TableClass.prototype.addRowSpacer = function(height, width, numCols)
  1140. {
  1141.    if(numCols == null && this.rows.length == 0)
  1142.    {
  1143.       return undefined;
  1144.    }
  1145.    numCols = this.rows[0].cells.length;
  1146.    var spacerRow = new TableRow();
  1147.    var spacerCell = null;
  1148.    var i = 0;
  1149.    while(i < numCols)
  1150.    {
  1151.       spacerCell = new TableCell();
  1152.       spacerCell.height = height;
  1153.       spacerCell.width = width;
  1154.       spacerRow.addCell(spacerCell);
  1155.       i++;
  1156.    }
  1157.    this.addRow(spacerRow);
  1158. };
  1159. TableClass.prototype.setCellPadding = function(cellPadding)
  1160. {
  1161.    this.cellPadding = cellPadding;
  1162.    this.redraw();
  1163. };
  1164. TableClass.prototype.setCellSpacing = function(cellSpacing)
  1165. {
  1166.    this.cellSpacing = cellSpacing;
  1167.    this.redraw();
  1168. };
  1169. TableClass.prototype.setWidth = function(width)
  1170. {
  1171.    this.oldWidth = this.width;
  1172.    this.width = width;
  1173.    this._recalcDimensions(width);
  1174.    this.redraw();
  1175.    this.redraw();
  1176. };
  1177. TableClass.prototype.setHeight = function(height)
  1178. {
  1179.    this.oldHeight = this.height;
  1180.    this.height = height;
  1181.    this.redraw();
  1182. };
  1183. TableClass.prototype.redraw = function()
  1184. {
  1185.    this.borderClip.clear();
  1186.    var rows = this.rows;
  1187.    var rc = rows.length;
  1188.    var tmdims = this.maxCellDims;
  1189.    var x;
  1190.    var y;
  1191.    var r;
  1192.    var cc;
  1193.    var con;
  1194.    var cols;
  1195.    var rmdims;
  1196.    var cell;
  1197.    var cmax;
  1198.    var offset;
  1199.    var voffset;
  1200.    var cwid;
  1201.    var wprec;
  1202.    var newwid;
  1203.    var lastColMax = null;
  1204.    var cpad = this.cellPadding;
  1205.    var cspace = this.cellSpacing;
  1206.    var r = 0;
  1207.    while(r < rc)
  1208.    {
  1209.       cols = rows[r].cells;
  1210.       cc = cols.length;
  1211.       rmdims = rows[r - 1].maxCellDims;
  1212.       if(r == 0)
  1213.       {
  1214.          y = this.y;
  1215.       }
  1216.       else
  1217.       {
  1218.          y += rmdims.height + this.cellSpacing;
  1219.       }
  1220.       var c = 0;
  1221.       while(c < cc)
  1222.       {
  1223.          cell = cols[c];
  1224.          con = cell.getContent();
  1225.          cwid = this.colWidthMaxs[c];
  1226.          this._resizeTextfield(con,cwid);
  1227.          if(cell.halign == "right")
  1228.          {
  1229.             offset = cwid - con._width;
  1230.          }
  1231.          else if(cell.halign == "center")
  1232.          {
  1233.             offset = (cwid - con._width) / 2;
  1234.          }
  1235.          else
  1236.          {
  1237.             offset = 0;
  1238.          }
  1239.          if(cell.valign == "bottom")
  1240.          {
  1241.             voffset = rows[r].maxCellDims.height - con._height;
  1242.          }
  1243.          else if(cell.valign == "center")
  1244.          {
  1245.             voffset = (rows[r].maxCellDims.height - con._height) / 2;
  1246.          }
  1247.          else
  1248.          {
  1249.             voffset = 0;
  1250.          }
  1251.          if(c == 0)
  1252.          {
  1253.             x = this.x;
  1254.             lastColMax = cwid;
  1255.          }
  1256.          else
  1257.          {
  1258.             cmax = lastColMax;
  1259.             x += cmax + this.cellSpacing;
  1260.          }
  1261.          con._x = x + offset;
  1262.          con._y = y + voffset;
  1263.          if(this.borderSize > 0)
  1264.          {
  1265.             this.borderClip.lineStyle(this.borderSize,10066329,100);
  1266.             this.borderClip.drawRect(x,y,cwid,rows[r].maxCellDims.height);
  1267.          }
  1268.          lastColMax = cwid;
  1269.          c++;
  1270.       }
  1271.       r++;
  1272.    }
  1273.    this._recalcHeights();
  1274. };
  1275. TableClass.prototype._resizeTextfield = function(oIns, w, h)
  1276. {
  1277.    var txt = oIns.content;
  1278.    if(txt._width > w)
  1279.    {
  1280.       txt.wordWrap = true;
  1281.       txt._width = w;
  1282.       txt._width = Math.round(txt._width);
  1283.       trace("text width: " + txt.textWidth);
  1284.       if(this.reduceTextFields)
  1285.       {
  1286.          var h = txt._height;
  1287.          var w = txt._width;
  1288.          var old_w = 0;
  1289.          var txtWidth = txt.textWidth;
  1290.          var i = w;
  1291.          while(h == txt._height)
  1292.          {
  1293.             if(i <= 0)
  1294.             {
  1295.                break;
  1296.             }
  1297.             if(txt.textWidth < txtWidth)
  1298.             {
  1299.                break;
  1300.             }
  1301.             txt._width--;
  1302.             i--;
  1303.          }
  1304.          txt._width = txt._width + 1;
  1305.       }
  1306.    }
  1307.    oIns._width = txt._width;
  1308. };
  1309. TableClass.prototype._recalcHeights = function()
  1310. {
  1311.    var rows = this.rows;
  1312.    var rc = rows.length;
  1313.    var cc;
  1314.    var cols;
  1315.    var cell;
  1316.    this.height = 0;
  1317.    var r = 0;
  1318.    while(r < rc)
  1319.    {
  1320.       cols = rows[r].cells;
  1321.       cc = cols.length;
  1322.       var c = 0;
  1323.       while(c < cc)
  1324.       {
  1325.          cell = cols[c];
  1326.          rows[r]._checkMaxCellDims(cell);
  1327.          this.height += rows[r].maxCellDims.height;
  1328.          c++;
  1329.       }
  1330.       r++;
  1331.    }
  1332. };
  1333. TableClass.prototype._findLargestColumn = function()
  1334. {
  1335.    var largestId;
  1336.    var largest;
  1337.    var cmaxs = this.colWidthMaxs;
  1338.    var i = 0;
  1339.    while(i < cmaxs.length)
  1340.    {
  1341.       trace("finding largest: " + cmaxs[i]);
  1342.       if(largest < cmaxs[i])
  1343.       {
  1344.          largest = cmaxs[i];
  1345.          largestId = i;
  1346.       }
  1347.       i++;
  1348.    }
  1349.    return largestId;
  1350. };
  1351. TableClass.prototype._recalcDimensions = function(newWidth)
  1352. {
  1353.    var cw = this._getTableWidth();
  1354.    if(newWidth > cw)
  1355.    {
  1356.       return undefined;
  1357.    }
  1358.    trace("\n\n----");
  1359.    trace("TableClass.prototype._recalcDimensions:");
  1360.    trace("current width: " + cw + ", new width: " + newWidth);
  1361.    delete this.alteredColumns;
  1362.    this.alteredColumns = {};
  1363.    this._resizeTableR(cw,newWidth);
  1364.    var addback = newWidth - this._getTableWidth();
  1365.    var cmaxs = this.colWidthMaxs;
  1366.    var prc;
  1367.    var cmax = 0;
  1368.    var acc = 0;
  1369.    for(var nm in this.alteredColumns)
  1370.    {
  1371.       trace("ALTERED COLUMNS: " + nm);
  1372.       if(!isNaN(nm))
  1373.       {
  1374.          acc++;
  1375.       }
  1376.    }
  1377.    for(var colid in this.alteredColumns)
  1378.    {
  1379.       trace("Addback: " + colid + ", " + addback / acc);
  1380.       this.colWidthMaxs[parseInt(colid)] = this.colWidthMaxs[parseInt(colid)] + addback / acc;
  1381.    }
  1382.    if(addback / acc > 0)
  1383.    {
  1384.    }
  1385.    this.width = newWidth;
  1386. };
  1387. TableClass.prototype._resizeTableR = function(lastWidth, targetWidth)
  1388. {
  1389.    if(lastWidth <= targetWidth)
  1390.    {
  1391.       return undefined;
  1392.    }
  1393.    var largest;
  1394.    var largestId = 0;
  1395.    var cmaxs = this.colWidthMaxs;
  1396.    var i = 0;
  1397.    while(i < cmaxs.length)
  1398.    {
  1399.       trace("finding largest: " + cmaxs[i]);
  1400.       if(largest < cmaxs[i])
  1401.       {
  1402.          largest = cmaxs[i];
  1403.          largestId = i;
  1404.       }
  1405.       i++;
  1406.    }
  1407.    var prc = largest / lastWidth;
  1408.    trace("prc: " + prc);
  1409.    var ncw = largest * prc;
  1410.    cmaxs[largestId] = ncw;
  1411.    this.alteredColumns[largestId] = largestId;
  1412.    trace("\n\nAFTER:");
  1413.    trace("new largest: " + ncw);
  1414.    trace("lastWidth: " + lastWidth);
  1415.    trace("largest: " + largest);
  1416.    trace("targetWidth: " + targetWidth);
  1417.    trace("nextWidth: " + (lastWidth - (largest - ncw)));
  1418.    if(prc == 1)
  1419.    {
  1420.       cmax[largestId] = targetWidth;
  1421.       return undefined;
  1422.    }
  1423.    this._resizeTableR(lastWidth - (largest - ncw),targetWidth);
  1424. };
  1425. TableClass.prototype._getTableWidth = function()
  1426. {
  1427.    var width = 0;
  1428.    var lasti = this.colWidthMaxs.length - 1;
  1429.    var i = 0;
  1430.    while(i < this.colWidthMaxs.length)
  1431.    {
  1432.       width += this.colWidthMaxs[i];
  1433.       i++;
  1434.    }
  1435.    return width;
  1436. };
  1437. TableClass.prototype.init = function()
  1438. {
  1439.    this.redraw();
  1440. };
  1441. TableRow = function()
  1442. {
  1443.    this.cells = [];
  1444.    this.maxCellDims = {width:0,height:0};
  1445. };
  1446. TableRow.prototype.addCell = function(cell)
  1447. {
  1448.    this.cells.push(cell);
  1449.    var cc = cell.getContent();
  1450.    var cw = cc == null ? cell.width : cc._width;
  1451.    var ch = cc == null ? cell.height : cc._height;
  1452.    var mw = this.maxCellDims.width;
  1453.    var mh = this.maxCellDims.height;
  1454.    this.maxCellDims.width = cw <= mw ? mw : cw;
  1455.    this.maxCellDims.height = ch <= mh ? mh : ch;
  1456. };
  1457. TableRow.prototype._checkMaxCellDims = function(cell)
  1458. {
  1459.    var cc = cell.getContent();
  1460.    var cw = cc == null ? cell.width : cc._width;
  1461.    var ch = cc == null ? cell.height : cc._height;
  1462.    var mw = this.maxCellDims.width;
  1463.    var mh = this.maxCellDims.height;
  1464.    this.maxCellDims.width = cw <= mw ? mw : cw;
  1465.    this.maxCellDims.height = ch <= mh ? mh : ch;
  1466. };
  1467. TableCell = function(content)
  1468. {
  1469.    this.content = content;
  1470. };
  1471. TableCell.prototype.setContent = function(content)
  1472. {
  1473.    this.content = content;
  1474. };
  1475. TableCell.prototype.getContent = function()
  1476. {
  1477.    return this.content;
  1478. };
  1479. TableCell.prototype.setWidth = function(width, isPercent)
  1480. {
  1481.    this.widthIsPercent = isPercent != null ? true : false;
  1482.    this.width = width;
  1483. };
  1484. TableCell.prototype.setHeight = function(height, isPercent)
  1485. {
  1486.    this.heightIsPercent = isPercent != null ? true : false;
  1487.    this.height = height;
  1488. };
  1489. TableCell.prototype.setHAlign = function(halign)
  1490. {
  1491.    this.halign = halign;
  1492. };
  1493. TableCell.prototype.setVAlign = function(valign)
  1494. {
  1495.    this.valign = valign;
  1496. };
  1497. Array.prototype.enqueue = function(obj)
  1498. {
  1499.    this.push(obj);
  1500. };
  1501. Array.prototype.dequeue = function()
  1502. {
  1503.    return this.shift();
  1504. };
  1505. Queue.prototype.enqueue = function(obj)
  1506. {
  1507.    this.q.enqueue(obj);
  1508. };
  1509. Queue.prototype.dequeue = function()
  1510. {
  1511.    return this.q.dequeue();
  1512. };
  1513. Queue.prototype.getSize = function()
  1514. {
  1515.    return this.q.length;
  1516. };
  1517. Queue.prototype.reset = function()
  1518. {
  1519.    delete this.q;
  1520.    this.q = new Array();
  1521. };
  1522. Queue.prototype.isEmpty = function()
  1523. {
  1524.    return this.getSize() == 0;
  1525. };
  1526. TextFormat.prototype.cGetTextExtent = function(s, bEmbedFonts, bAccurate)
  1527. {
  1528.    var __CGTE_mc = _root.createEmptyMovieClip("__PMSI_textExtBox__",4013145);
  1529.    __CGTE_mc._visible = false;
  1530.    __CGTE_mc.createTextField("content",1,0,0,0,0);
  1531.    var __CGTE_mc_txt = __CGTE_mc.content;
  1532.    __CGTE_mc_txt.autoSize = true;
  1533.    var __CGTE_marg_h = bAccurate != true ? 0 : __CGTE_mc_txt._height;
  1534.    var __CGTE_marg_v = bAccurate != true ? 0 : __CGTE_mc_txt._width;
  1535.    __CGTE_mc_txt.embedFonts = bEmbedFonts != null ? bEmbedFonts : true;
  1536.    __CGTE_mc_txt.type = "dynamic";
  1537.    __CGTE_mc_txt.selectable = false;
  1538.    __CGTE_mc_txt.text = s;
  1539.    __CGTE_mc_txt.setTextFormat(this);
  1540.    return {width:__CGTE_mc_txt._width - __CGTE_marg_h,height:__CGTE_mc_txt._height - __CGTE_marg_v};
  1541. };
  1542. TextField.prototype.findLines = function(ttf)
  1543. {
  1544.    var mc2 = _root.createEmptyMovieClip("__getLinesBox__",4013146);
  1545.    mc2._visible = false;
  1546.    ttf = ttf != null ? ttf : this.getTextFormat();
  1547.    var lh = ttf.cGetTextExtent("373_<3_4").height;
  1548.    var lines = [];
  1549.    mc2.createTextField("__fio__",1000,0,0,0,0);
  1550.    var f = mc2.__fio__;
  1551.    var als = this.text.split(" ");
  1552.    f._width = this._width;
  1553.    f.embedFonts = this.embedFonts;
  1554.    f.border = this.border;
  1555.    f.type = "dynamic";
  1556.    f.autoSize = true;
  1557.    f.selectable = false;
  1558.    f.wordWrap = true;
  1559.    f.multiline = true;
  1560.    var line = "";
  1561.    var i = 0;
  1562.    while(i < als.length)
  1563.    {
  1564.       f.text += " " + als[i];
  1565.       f.setTextFormat(ttf);
  1566.       if(f._height > lh && line != "")
  1567.       {
  1568.          lines.push(line.trim());
  1569.          f.text = "";
  1570.          line = "";
  1571.          i--;
  1572.       }
  1573.       line = f.text;
  1574.       f.setTextFormat(ttf);
  1575.       i++;
  1576.    }
  1577.    lines.push(f.text.trim());
  1578.    f.removeTextField();
  1579.    this.__lines = lines;
  1580.    return lines;
  1581. };
  1582. TextField.prototype.getLineAt = function(i)
  1583. {
  1584.    if(this.__lines == null)
  1585.    {
  1586.       this.findLines();
  1587.    }
  1588.    return this.__lines[i];
  1589. };
  1590. TextField.prototype.getLineCount = function()
  1591. {
  1592.    if(this.__lines == null)
  1593.    {
  1594.       this.findLines();
  1595.    }
  1596.    return this.__lines.length;
  1597. };
  1598. TextField.prototype.convertToLines = function()
  1599. {
  1600.    if(this.__lines == null)
  1601.    {
  1602.       this.findLines();
  1603.    }
  1604.    this.text = "";
  1605.    var i = 0;
  1606.    while(i < this.__lines.length - 1)
  1607.    {
  1608.       this.text += this.__lines[i] + "\n";
  1609.       i++;
  1610.    }
  1611.    this.text += this.__lines[this.__lines.length - 1];
  1612. };
  1613. TextField.prototype.getLines = function()
  1614. {
  1615.    if(this.__lines == null)
  1616.    {
  1617.       this.findLines();
  1618.    }
  1619.    return this.__lines;
  1620. };
  1621. var DIALOG_DEPTH = 1200;
  1622. loadingBox._visible = false;
  1623. if(_parent)
  1624. {
  1625.    this._visible = false;
  1626.    if(_parent.isTester != true)
  1627.    {
  1628.       btnToggleLang._visible = false;
  1629.    }
  1630. }
  1631. refPath = "reference";
  1632. videoPath = "video";
  1633. audioPath = "audio/listening";
  1634. artPath = "artfiles";
  1635. scriptPath = "activities/scripts";
  1636. videoSetupPath = videoPath;
  1637. testFile = "test_dialog.xml";
  1638. templateQueue = new Queue();
  1639. templateList = [];
  1640. templateList[0] = {};
  1641. templateList[0].file = "template1.swf";
  1642. templateList[0].name = "template1";
  1643. templateList[1] = {};
  1644. templateList[1].file = "template2.swf";
  1645. templateList[1].name = "template2";
  1646. templateList[2] = {};
  1647. templateList[2].file = "template3.swf";
  1648. templateList[2].name = "template3";
  1649. templateList[3] = {};
  1650. templateList[3].file = "template4.swf";
  1651. templateList[3].name = "template4";
  1652. templateList[4] = {};
  1653. templateList[4].file = "template5.swf";
  1654. templateList[4].name = "template5";
  1655. templateList[5] = {};
  1656. templateList[5].file = "template6.swf";
  1657. templateList[5].name = "template6";
  1658. templateList[6] = {};
  1659. templateList[6].file = "template7.swf";
  1660. templateList[6].name = "template7";
  1661. var i = 0;
  1662. while(i < templateList.length)
  1663. {
  1664.    templateQueue.enqueue(templateList[i]);
  1665.    i++;
  1666. }
  1667. activityTypes = [];
  1668. activityTypes.SWITCH = 1;
  1669. activityTypes.FILL_IN = 2;
  1670. activityTypes.SHORT = 3;
  1671. activityTypes.MATCH = 4;
  1672. activityTypes.MULTI = 5;
  1673. activityTypes.TABLE = 6;
  1674. activityTypes.VIDEO = 7;
  1675. activityTypes[activityTypes.SWITCH] = "template1";
  1676. activityTypes[activityTypes.FILL_IN] = "template2";
  1677. activityTypes[activityTypes.SHORT] = "template3";
  1678. activityTypes[activityTypes.MATCH] = "template4";
  1679. activityTypes[activityTypes.MULTI] = "template5";
  1680. activityTypes[activityTypes.TABLE] = "template6";
  1681. activityTypes[activityTypes.VIDEO] = "template7";
  1682. styles = {};
  1683. styles.VIDEO = 1;
  1684. styles.ART = 2;
  1685. styles.AUDIO = 3;
  1686. actBulletPosition = {};
  1687. actBulletPosition.topx = actBullet._x;
  1688. actBulletPosition.topy = actBullet._y;
  1689. actBulletPosition.botx = 0;
  1690. actBulletPosition.boty = 0;
  1691. actAnswerPosition = {};
  1692. actAnswerPosition.inix = 457;
  1693. actAnswerPosition.iniy = 500;
  1694. actAnswerPosition.secx = 694;
  1695. actAnswerPosition.secy = 500;
  1696. actAnswerPosition.pos1_x = 694;
  1697. actAnswerPosition.pos1_y = 500;
  1698. actAnswerPosition.pos2_x = 694;
  1699. actAnswerPosition.pos2_y = 436;
  1700. var layoutInfo = {};
  1701. layoutInfo.actBulletTextColor = 16777215;
  1702. layoutInfo.titleTextColor = 10053375;
  1703. layoutInfo.answerRollOverColor = 16695085;
  1704. layoutInfo.answerRollOutColor = layoutInfo.titleTextColor;
  1705. layoutInfo.answerSelectColor = layoutInfo.titleTextColor;
  1706. layoutInfo.questionTextColor = 2309272;
  1707. layoutInfo.instTextColor = 2309272;
  1708. layoutInfo.answerIncorrectColor = 16695085;
  1709. layoutInfo.doAnswerFill = false;
  1710. layoutInfo.rightSideBuffer = 10;
  1711. layoutInfo.box = {};
  1712. layoutInfo.box.x = 260;
  1713. layoutInfo.box.y = 93;
  1714. layoutInfo.box.views = [];
  1715. layoutInfo.box.widthWithBox = 300;
  1716. layoutInfo.box.heightWithBox = 300;
  1717. layoutInfo.box.widthWithoutBox = 300;
  1718. layoutInfo.box.heightWithoutBox = 300;
  1719. layoutinfo.MAX_WIDTH = 520;
  1720. layoutInfo.MAX_HEIGHT = 380;
  1721. layoutInfo.questionIndent = 30;
  1722. layoutInfo.selectionRadius = 6;
  1723. layoutInfo.drawSelectionCircle = true;
  1724. layoutInfo.lineSpacing = 5;
  1725. layoutInfo.selectionBorderThickness = 1;
  1726. layoutInfo.instTextFormat = new TextFormat();
  1727. layoutInfo.instTextFormat.font = "Formata_Normal";
  1728. layoutInfo.instTextFormat.size = 12;
  1729. layoutInfo.instTextFormat.color = layoutInfo.instTextColor;
  1730. layoutInfo.instTextFormatBold = new TextFormat();
  1731. layoutInfo.instTextFormatBold.font = "Formata_Bold";
  1732. layoutInfo.instTextFormatBold.size = 12;
  1733. layoutInfo.instTextFormatBold.color = layoutInfo.instTextColor;
  1734. layoutInfo.qTextFormat = new TextFormat();
  1735. layoutInfo.qTextFormat.font = "Formata_Normal";
  1736. layoutInfo.qTextFormat.size = 12;
  1737. layoutInfo.qTextFormat.color = layoutInfo.questionTextColor;
  1738. layoutInfo.qTextFormat.align = "right";
  1739. layoutInfo.qTextFormat.leading = 2;
  1740. layoutInfo.qTextFormatSA = new TextFormat();
  1741. layoutInfo.qTextFormatSA.font = "Formata_Normal";
  1742. layoutInfo.qTextFormatSA.size = 12;
  1743. layoutInfo.qTextFormatSA.color = layoutInfo.questionTextColor;
  1744. layoutInfo.qTextFormatSA.leading = 2;
  1745. layoutInfo.qTextFormatMATCH = new TextFormat();
  1746. layoutInfo.qTextFormatMATCH.font = "Formata_Normal";
  1747. layoutInfo.qTextFormatMATCH.size = 12;
  1748. layoutInfo.qTextFormatMATCH.color = layoutInfo.questionTextColor;
  1749. layoutInfo.qTextFormatMATCH.leading = 2;
  1750. layoutInfo.qTextFormatBANK = new TextFormat();
  1751. layoutInfo.qTextFormatBANK.font = "Formata_Normal";
  1752. layoutInfo.qTextFormatBANK.size = 12;
  1753. layoutInfo.qTextFormatBANK.color = layoutInfo.questionTextColor;
  1754. layoutInfo.qTextFormatBANK.leading = 2;
  1755. layoutInfo.qTextFormatMULTI = new TextFormat();
  1756. layoutInfo.qTextFormatMULTI.font = "Formata_Normal";
  1757. layoutInfo.qTextFormatMULTI.size = 12;
  1758. layoutInfo.qTextFormatMULTI.color = layoutInfo.questionTextColor;
  1759. layoutInfo.qTextFormatMULTI.leading = 2;
  1760. layoutInfo.answerTextFormat1 = new TextFormat();
  1761. layoutInfo.answerTextFormat1.font = "Formata_Normal";
  1762. layoutInfo.answerTextFormat1.size = 12;
  1763. layoutInfo.answerTextFormat1.color = layoutInfo.answerRollOutColor;
  1764. layoutInfo.answerTextFormat2 = new TextFormat();
  1765. layoutInfo.answerTextFormat2.font = "Formata_Normal";
  1766. layoutInfo.answerTextFormat2.size = 12;
  1767. layoutInfo.answerTextFormat2.color = layoutInfo.answerRollOutColor;
  1768. layoutInfo.titleTextFormat = new TextFormat();
  1769. layoutInfo.titleTextFormat.font = "TriplexCondSerifBlack";
  1770. layoutInfo.titleTextFormat.size = 24;
  1771. layoutInfo.titleTextFormat.color = layoutInfo.titleTextColor;
  1772. layoutInfo.actBulletTextFormat = new TextFormat();
  1773. layoutInfo.actBulletTextFormat.font = "Formata_Bold";
  1774. layoutInfo.actBulletTextFormat.bold = true;
  1775. layoutInfo.actBulletTextFormat.size = 14;
  1776. layoutInfo.actBulletTextFormat.color = layoutInfo.actBulletTextColor;
  1777. layoutInfo.actFeedbackColor = 10053375;
  1778. layoutInfo.actCorrectFeedbackColor = 16695085;
  1779. layoutInfo.actFeedbackTextFormat = new TextFormat();
  1780. layoutInfo.actFeedbackTextFormat.font = "Formata_Bold";
  1781. layoutInfo.actFeedbackTextFormat.size = 15;
  1782. layoutInfo.actFeedbackTextFormat.color = layoutInfo.actFeedbackColor;
  1783. layoutInfo.actCorrectFeedbackTextFormat = new TextFormat();
  1784. layoutInfo.actCorrectFeedbackTextFormat.font = "Formata_Bold";
  1785. layoutInfo.actCorrectFeedbackTextFormat.size = 15;
  1786. layoutInfo.actCorrectFeedbackTextFormat.color = layoutInfo.actCorrectFeedbackColor;
  1787. layoutInfo.matchingCircleColor = 16695085;
  1788. layoutInfo.matchingCircleRadius = 4;
  1789. layoutInfo.matchingCircleSpacer = 50;
  1790. layoutInfo.matchingCircleLineThickness = 2;
  1791. layoutInfo.matchingCircleVertOffset = 4;
  1792. answerBtn.onRelease = function()
  1793. {
  1794.    this.onRollOut();
  1795.    this._parent.currentActivity.checkAnswers();
  1796. };
  1797. answerBtn.onRollOver = function()
  1798. {
  1799.    this.gotoAndStop("rollOver");
  1800. };
  1801. answerBtn.onRollOut = function()
  1802. {
  1803.    this.gotoAndStop("rollOut");
  1804. };
  1805. answerBtn.onReleaseOutside = answerBtn.onRollOut;
  1806. actInfo = new ActivityInfo();
  1807. btnRefWin.onRollOver = function()
  1808. {
  1809.    this.gotoAndStop(2);
  1810. };
  1811. btnRefWin.onRollOut = function()
  1812. {
  1813.    this.gotoAndStop(1);
  1814. };
  1815. btnRefWin.onRelease = function()
  1816. {
  1817.    setRefWinVisible(true);
  1818.    refWin.loadPaneSwf(refPath + "/" + ai.reference.file.text,parseInt(ai.reference.x.text),parseInt(ai.reference.y.text),parseInt(ai.reference.zoom.text));
  1819. };
  1820. btnRefWin.onReleaseOutside = btnRefWin.onRollOut;
  1821.